﻿@using SCMS.Resources
@model SCMS.UI.Models.ChildtRequest
@{string extraFn = Model.EntityOrderRequestItem.Id != Guid.Empty ? "CloseDialog();" : "";}
@{AjaxOptions ajaxOpts = new AjaxOptions
      {
          UpdateTargetId = "requestItemDiv",
          LoadingElementId = "loading",
          HttpMethod = "Post",
          Url = Url.Action("LoadRequestItem/" + ViewBag.OrderRequestID),
          OnBegin = "checkBalance",
          OnSuccess = string.Format("usermsgg('{0}'); ClearFormById('#' + 'frmORItem');" + extraFn, Resources_frank.OrderRequest_AddItemInEditMode_SuccessMsg)
      };}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form", @id = "frmORItem" }))
{
    @Html.ValidationSummary(true)
        <table>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_ItemName:
                </td>
                <td align="left" class="editor-field" colspan="4">
                    @Html.DropDownListFor(model => model.ItemID, Model.Items, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(model => model.ItemID, Resources_frank.Global_String_Required)
                    @Html.HiddenFor(model => model.EntityOrderRequestItem.Id)
                    @Html.HiddenFor(model => model.EntityOrderRequestItem.OrderRequestId)
                </td>
                <td title="@Resources_frank.OrderRequest_AddNewItem4OR_AddNewItem">
                    <a href="#" onclick="sendRequest('/OrderRequest/AddNewItem/@ViewBag.OrderRequestID', 'popup-page', 'popup-loading');CenterPopup();"><img src="../../Content/images/Add-Green-Button-icon.png" alt="@Resources_frank.OrderRequest_AddNewItem4OR_AddNewItem" /></a>
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.Global_String_Description:
                </td>
                <td align="left" class="editor-field" colspan="4">
                    @Html.TextAreaFor(model => model.Description)
                    @Html.ValidationMessageFor(model => model.Description)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_Quantity:
                </td>
                <td align="left" class="editor-field">@Html.TextBoxFor(model => model.EntityOrderRequestItem.Quantity, new { id = "Quatity", onblur = "javascript:ComputeTotals()", @autocomplete = "off", @class = "numericTb" })
                    @Html.ValidationMessageFor(model => model.EntityOrderRequestItem.Quantity)
                </td>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.OrderRequest_AddItemInEditMode_EstUnitPrice:
                </td>
                <td align="left" class="editor-field" colspan="2">
                    @Html.TextBoxFor(model => model.UnitpPrice, new { id = "UnityPrice", onblur = "javascript:ComputeTotals()", @autocomplete = "off", @class = "numericTb" })
                    @Html.ValidationMessageFor(model => model.UnitpPrice)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.OrderRequest_AddItemInEditMode_EstTotalPrice:
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(model => model.TotalPrice, new { id = "TotalPrice", @readonly = "readonly", @class = "numericTb" })
                    @Html.ValidationMessageFor(model => model.TotalPrice)
                </td>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.Budget_CreateSubLine_LineNumber:
                </td>
                <td align="left" class="editor-field" colspan="2">
                    <div id="PBlines">
                        @Html.DropDownListFor(model => model.BudgetLineID, Model.BudgetLines, Resources_frank.Global_String_PleaseSelect, new { @class = "dpl", @id = "BudgetLineID", onchange = "javascript:checkBalance()" })
                        @Html.ValidationMessageFor(model => model.BudgetLineID, Resources_frank.Global_String_Required)
                    </div>
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_Remarks:
                </td>
                <td align="left" class="editor-field" colspan="4">
                    @Html.TextAreaFor(model => model.Remarks)
                    @Html.ValidationMessageFor(model => model.Remarks)
                </td>
            </tr>
            <tr>
                <td align="left" class="editor-label">
                </td>
                <td align="left" class="editor-field">
                </td>
                <td align="left" class="editor-label" colspan="2" id="fundsCheck" valign="top">
                </td>
            </tr>
            <tr>
                <td align="left" class="editor-label">
                </td>
                <td align="left" class="editor-field">
                    <input type="submit" class="btn green"  value="@ViewBag.Action" />
                </td>
                <td align="left" class="editor-label" colspan="2" valign="top">
                </td>
            </tr>
        </table>
}